<template>
    <div class="addSupplier">
        <el-card>
            <el-button type="info" size="small" icon="el-icon-arrow-left"
                @click="backToPrev">
                返回</el-button>
            <el-form size="small" class="addForm">
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-form-item required>
                            <span slot="label">
                                <span class="labelText">类型</span>
                            </span>
                            <div class="choose">
                                <el-select v-model="addForm.type"
                                    placeholder="请选择类型">
                                    <el-option label="公海" value="1"></el-option>
                                    <el-option label="私海" value="0"></el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                        <el-form-item required>
                            <span slot="label">
                                <span class="labelText">供应商名称</span>
                            </span>
                            <el-input v-model="addForm.name"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商类型</span>
                            </span>
                            <el-input v-model="addForm.providerType"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商级别</span>
                            </span>
                            <div class="choose">
                                <el-select v-model="addForm.level"
                                    placeholder="请选择级别">
                                    <el-option label="1星" value="1"></el-option>
                                    <el-option label="2星" value="2"></el-option>
                                    <el-option label="3星" value="3"></el-option>
                                    <el-option label="4星" value="4"></el-option>
                                    <el-option label="5星" value="5"></el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商状态</span>
                            </span>
                            <el-input v-model="addForm.intention"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">所属行业</span>
                            </span>
                            <el-input v-model="addForm.industry"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">员工数量</span>
                            </span>
                            <el-input v-model="addForm.employeeNum"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">公司网址</span>
                            </span>
                            <el-input v-model="addForm.webAddr"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">状态</span>
                            </span>
                            <div class="choose">
                                <el-select v-model="addForm.status"
                                    placeholder="请选择状态">
                                    <el-option label="有效" value="0"></el-option>
                                    <el-option label="无效" value="1"></el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商简拼</span>
                            </span>
                            <el-input v-model="addForm.spell"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商标签</span>
                            </span>
                            <el-input v-model="addForm.tag"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商属性</span>
                            </span>
                            <el-input v-model="addForm.attribute"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商来源</span>
                            </span>
                            <el-input v-model="addForm.source"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">公司性质</span>
                            </span>
                            <el-input v-model="addForm.details"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">营业执照</span>
                            </span>
                            <el-input v-model="addForm.license"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">供应商备注</span>
                            </span>
                            <el-input v-model="addForm.remark"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <hr>
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">联系人</span>
                            </span>
                            <el-input v-model="addForm.contact"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">办公电话</span>
                            </span>
                            <el-input v-model="addForm.officePhone"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">Email</span>
                            </span>
                            <el-input v-model="addForm.email"> </el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">微信</span>
                            </span>
                            <el-input v-model="addForm.wechat"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">手机号码</span>
                            </span>
                            <el-input v-model="addForm.contactPhone"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">传真</span>
                            </span>
                            <el-input v-model="addForm.fax"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">QQ</span>
                            </span>
                            <el-input v-model="addForm.qq"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">旺旺</span>
                            </span>
                            <el-input v-model="addForm.wangwang"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <hr>
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">国家</span>
                            </span>
                            <el-input v-model="addForm.nation"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">市</span>
                            </span>
                            <el-input v-model="addForm.city"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">地址</span>
                            </span>
                            <el-input v-model="addForm.address"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">省</span>
                            </span>
                            <el-input v-model="addForm.province"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">区</span>
                            </span>
                            <el-input v-model="addForm.area"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <span slot="label">
                                <span class="labelText">邮编</span>
                            </span>
                            <el-input v-model="addForm.postCode"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-form-item class="subBtn">
                    <el-button type="primary" @click="onSubmit">保存</el-button>
                    <el-button @click="backToPrev">取消</el-button>
                </el-form-item>
            </el-form>

        </el-card>

    </div>
</template>
  
<script>


import dayjs from 'dayjs'

export default {
    name: '',
    data() {
        return {
            addForm: {
                "address": "",
                "area": "",
                "attribute": "",
                "city": "",
                "companyCreateTime": "",
                "contact": "",
                "contactPhone": "",
                "createTime": "",
                "details": "",
                "email": "",
                "employeeNum": 0,
                "fax": "",
                // "id": 0,
                "industry": "",
                "intention": "",
                "level": '',
                "license": "",
                "name": "",
                "nation": "",
                "nature": "",
                "officePhone": "",
                "postCode": "",
                "providerType": "",
                "province": "",
                "qq": "",
                "remark": "",
                "source": "",
                "spell": "",
                "status": '',
                "tag": "",
                "type": '',
                "updateTime": "",
                "userId": 1,
                "wangwang": "",
                "webAddr": "",
                "wechat": ""
            }
        }
    },
    components: {

    },
    methods: {
        dayjs,
        backToPrev() {
            this.$router.push('/supply/supManage')
        },
        async onSubmit() {
            // this.addForm.createTime = dayjs().format("YYYY-MM-DD HH:mm");
            this.addForm.userId=sessionStorage.getItem('userID')
            this.addForm.createTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
            console.log(this.addForm.createTime);
            let res = await this.$api.supply.addSupplier(this.addForm)
            console.log(res);
            if (res.data.code === 200) {
                //跳转到列表页面
                this.$router.push('/supply/supManage')
                //提示
                this.$message({
                    message: '恭喜你，添加供应商成功',
                    type: 'success'
                });
            } else {
                //错误信息提示
                this.$message.error('出现错误，添加失败');
            }
        }
    }
}
</script>

<style scoped>
.addSupplier {
    margin: 20px 5px 0;
}

.labelText {
    font-size: 14px;
    font-weight: 600;
    color: #000;
}

hr {
    height: 0px;
    border: 1px solid #6c7b8b;
}

.subBtn {
    text-align: center;
}

.choose>>>.el-select {
    display: block;
}

.choose>>>.el-select .el-input__suffix {
    top: 15px;
}
</style>

